package root.electronclass.electronclass.mvp.rest

import root.electronclass.electronclass.mvp.GlobalParameter
import root.electronclass.electronclass.mvp.base.BaseResponse
import root.electronclass.electronclass.grade.model.*
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

/**
 *
 * @author Lokiy
 * @date 2023/3/15 22:07
 */
interface ClassApi {

    companion object {
        val service: ClassApi
            get() = RestManager.getInstance().classRest()
    }

    /**
     * 班级通知分页
     */
    @POST("classManage/ecardApp/noticePage")
    suspend fun getClassNoticeList(@Body query: NoticeQuery): BaseResponse<PageResult<ClassNotification>>?

    /**
     * 班级空间-班级通知，修改未读状态
     */
    @GET("classManage/ecardApp/updateNoticeStatus")
    suspend fun updateNoticeStatus(@Query("relationId") relationId : String): BaseResponse<Any>?

    /**
     * 班级通知分页
     */
    @POST("classManage/ecardApp/honorPage")
    suspend fun getClassHonorList(@Body query: HonorQuery): BaseResponse<PageResult<ClassHonor>>?

    /**
     * 班级空间-班级风采
     */
    @POST("classManage/ecardApp/catchPage")
    suspend fun getClassRecordList(@Body query: RecordQuery): BaseResponse<PageResult<ClassRecord>>?

    /**
     * 班级空间-课程表
     * @param endDate  yyyy-MM-dd
     */
    @GET("classManage/ecardApp/timetableWeekList")
    suspend fun getClassCurriculum(
        @Query("startDate") startDate: String,// yyyy-MM-dd
        @Query("endDate") endDate: String,// yyyy-MM-dd
        @Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()
    ): BaseResponse<LinkedHashMap<String, List<ClassCurriculumItem>>>?

    /**
     * 班级空间-值日表-根据日期查询值日
     * @param date  yyyy-MM-dd
     */
    @GET("classManage/ecardApp/duty/listByDate")
    suspend fun getClassRotaByDate(
        @Query("date") date: String,// yyyy-MM-dd
        @Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()
    ): BaseResponse<List<ClassRotaItem>>?

    /**
     * 班级空间-值日表-查询值日项
     */
    @GET("classManage/ecardApp/duty/getItemList")
    suspend fun getClassRotaList(
        @Query("schoolId") schoolId: String = GlobalParameter.getEcardInfo().schoolId.toString()
    ): BaseResponse<List<ClassRota>>?

    /**
     * 班级空间-值日表-删除值日项
     */
    @POST("classManage/ecardApp/duty/deleteItem")
    suspend fun deleteClassRota(
        @Body ids: List<String>
    ): BaseResponse<Any>?

    /**
     * 班级空间-值日表-添加值日项
     */
    @POST("classManage/ecardApp/duty/addItem")
    suspend fun addClassRota(
        @Body body: ClassRota
    ): BaseResponse<Any>?


    /**
     * 查询班级下的学生列表
     */
    @GET("classManage/ecardApp/duty/listByDepartId")
    suspend fun getAllStudentList(
        @Query("departId") id: String = GlobalParameter.getEcardInfo().classId.toString()
    ): BaseResponse<List<Person>>?

    /**
     * 班级空间-值日表-添加值日生
     */
    @POST("classManage/ecardApp/duty/addUser")
    suspend fun addClassRotaUser(
        @Body body: RotaUser
    ): BaseResponse<Any>?

    /**
     * 班级空间-班级作业，根据日期查询
     * @param date  yyyy-MM-dd
     */
    @GET("classManage/ecardApp/homeworkByDate")
    suspend fun getHomeworkByDate(
        @Query("date") date: String,// yyyy-MM-dd
        @Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()
    ): BaseResponse<List<ClassHomeworkItem>>?


    /**
     * 班级空间-班级作业，作业量统计
     */
    @POST("classManage/ecardApp/getHomeworkStat")
    suspend fun getHomeworkStat(@Body query: HomeworkStatQuery): BaseResponse<List<ClassHomeworkItem>>?

    /**
     * 班级空间-班级作业，作业统计详情分页
     */
    @POST("classManage/ecardApp/homeworkUserPage")
    suspend fun getHomeworkUserPage(@Body query: HomeworkDetailQuery): BaseResponse<PageResult<ClassHomeworkUser>>?

    /**
     * 班级空间-班级作业，作业统计详情分页
     */
    @GET("classManage/ecardApp/finishRate")
    suspend fun getHomeworkFinishRate(@Query("homeworkId") homeworkId: String): BaseResponse<Float>?


    /**
     * 班级空间-班级作业，提交作业
     */
    @POST("classManage/ecardApp/submitHomework/save2")
    suspend fun submitHomework2(@Body body: ClassSubmitHomework2): BaseResponse<Any>?


    /**
     * 班级空间-班级作业，提交作业的详情页
     * @param subjectType 1-单科提交 2-多科提交
     * @param type 1-个人提交, 2班级提交
     */
    @GET("classManage/ecardApp/submitHomework/detail2")
    suspend fun submitHomeworkDetail2(@Query("homeworkId") homeworkId: String? = null, @Query("subjectId") subjectId: Long? = null,
                                      @Query("subjectType") subjectType: Int? = null, @Query("type") type: Int? = null): BaseResponse<ClassSubmitHomework2>?



    /**
     * 班级空间-班级作业，提交作业的科目列表
     */
    @GET("classManage/ecardApp/submitHomework/subjectList")
    suspend fun submitHomeworkSubjectList(): BaseResponse<List<ClassSubmitHomeworkSubject>>?


    /**
     * 班级空间-班级成员墙-教职工
     */
    @GET("classManage/ecardApp/member/getTeacherList")
    suspend fun getTeacherList(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<List<Person>>?

    /**
     * 班级空间-班级成员墙-班干部
     */
    @GET("classManage/ecardApp/member/getStudentList")
    suspend fun getStudentList(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<List<Person>>?

    /**
     * 班级空间-班级驾驶舱-班级考勤
     * @param type 1-个人 2-集体
     */
    @GET("classManage/ecardApp/honorRank")
    suspend fun getIndexHonorRank(
        @Query("type") type: Int,
        @Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()
    ): BaseResponse<ClassIndexAttnRank>?

    /**
     * 班级空间-班级驾驶舱-班级考勤
     */
    @GET("classManage/ecardApp/attnRank")
    suspend fun getIndexAttnRank(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<ClassIndexAttnRank>?

    /**
     * 班级空间-班级驾驶舱-班级风采
     */
    @GET("classManage/ecardApp/catchRank")
    suspend fun getIndexCatchRank(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<ClassIndexAttnRank>?

    /**
     * 班级空间-班级驾驶舱-班级人员动态
     */
    @GET("classManage/ecardApp/departStudentStat")
    suspend fun getIndexDepartStudentStat(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<ClassIndexStudentStatus>?

    /**
     * 班级空间-班级驾驶舱-班级通知
     */
    @GET("classManage/ecardApp/getClassInfo")
    suspend fun getIndexClassInfo(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<ClassInfo>?

    /**
     * 班级空间-班级驾驶舱-班级通知
     */
    @GET("classManage/ecardApp/noticeRank")
    suspend fun getIndexNoticeRank(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<ClassIndexAttnRank>?

    /**
     * 班级空间-班级驾驶舱-班级作业
     */
    @GET("classManage/ecardApp/homeworkChart")
    suspend fun getIndexHomeworkChart(@Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()): BaseResponse<ClassIndexHomeworkChart>?

    /**
     * 班级空间-班级优秀生-分页
     */
    @POST("classManage/ecardApp/excellent/page")
    suspend fun getExcellentStudentList(@Body query: ExcellentPageQuery): BaseResponse<PageResult<Person>>?

    /**
     * 班级空间-班级优秀生-学期列表
     */
    @GET("classManage/ecardApp/excellent/getTermList")
    suspend fun getTermList(@Query("schoolId") schoolId: String = GlobalParameter.getEcardInfo().schoolId.toString()): BaseResponse<List<Semester>>?

    /**
     * 班级空间-班级驾驶舱-班级德育-竞赛
     */
    @POST("api/pub/moralClassScore/competitionList")
    suspend fun getIndexMoralScoreRecordCompetitionScoreList(@Body query: Any = Any()): BaseResponse<ClassIndexRank>?

    /**
     * 班级空间-班级驾驶舱-班级德育-校园
     */
    @POST("api/pub/moralClassScore/list")
    suspend fun getIndexMoralScoreRecordStudentScoreList(@Body query: Any = Any()): BaseResponse<ClassIndexRank>?

    /**
     * 班级空间-班级驾驶舱-德育优秀生-竞赛
     */
    @POST("api/pub/moralStudentScore/competitionList")
    suspend fun getIndexMoralStudentScoreCompetitionList(@Body query: Any = Any()): BaseResponse<ClassIndexRank>?

    /**
     * 班级空间-班级驾驶舱-德育优秀生-校园
     */
    @POST("api/pub/moralStudentScore/list")
    suspend fun getIndexMoralStudentScoreList(@Body query: Any = Any()): BaseResponse<ClassIndexRank>?

    /**
     * 班级空间-班级驾驶舱-课程统计
     */
    @POST("api/pub/schoolCourseSign/list")
    suspend fun getIndexSchoolCourseSignList(@Body query: ClassSignStatQuery = ClassSignStatQuery()): BaseResponse<List<ClassSignStat>>?

    /**
     * 班级空间-历史考勤统计
     * @param type 1-本周 2-本月 3-3个月 4-本学期
     */
    @GET("classManage/ecardApp/historyAttn")
    suspend fun getClassAttnList(
        @Query("type") type: String,
        @Query("departId") departId: String = GlobalParameter.getEcardInfo().classId.toString()
    ): BaseResponse<List<ClassAttendanceReport>>?

    /**
     * 个人空间-个人考勤
     */
    @POST("classManage/ecardApp/studentAttn")
    suspend fun getStudentAttnList(@Body query: PersonalAttendanceStatQuery): BaseResponse<PageResult<AttendanceReport>>?

    /**
     * 个人空间-个人考勤统计
     */
    @GET("classManage/ecardApp/studentAttnDetail")
    suspend fun getStudentAttnStat(
        @Query("type") type: Int,
        @Query("userId") id: String = GlobalParameter.getSTUDENT()?.userInfoVo?.id.toString(),
        @Query("schoolId") schoolId: String = GlobalParameter.getEcardInfo().schoolId.toString()
    ): BaseResponse<AttendanceStat>?

    /**
     * 个人空间-个人考勤-详情
     */
    @GET("classManage/ecardApp/studentAttn")
    suspend fun getStudentAttnDetail(@Query("id") id: String): BaseResponse<List<AttendanceInfo>>?

    /**
     * 个人空间-个人消费
     */
    @POST("classManage/ecardApp/payRecordPage")
    suspend fun getStudentPayRecordPage(@Body query: StuPayRecordQuery): BaseResponse<PageResult<CanteenPayRecord>>?

    /**
     * 个人空间-一周个人消费趋势
     */
    @GET("classManage/ecardApp/weekList")
    suspend fun getStudentPayRecordWeekList(
        @Query("userId") userId: Long = GlobalParameter.getSTUDENT()?.id!!,
        @Query("schoolId") schoolId: String = GlobalParameter.getEcardInfo().schoolId.toString()
    ): BaseResponse<List<CanteenStatUser>>?

    /**
     * 个人空间-一周个人消费统计
     */
    @GET("classManage/ecardApp/weekStat")
    suspend fun getStudentPayRecordWeekStat(
        @Query("userId") userId: Long = GlobalParameter.getSTUDENT()?.id!!,
        @Query("schoolId") schoolId: String = GlobalParameter.getEcardInfo().schoolId.toString()
    ): BaseResponse<CanteenStatUser>?


    /**
     * 查询当前登录帐号的用户信息
     */
    @GET("api/pub/dzbp/login/self")
    suspend fun login(): BaseResponse<PersonLoginResult>?
}